package com.demo.modalframe3.listener;

import com.demo.modalframe3.utils.AppendTextFrame;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class DialogCloseListener extends WindowAdapter {

    AppendTextFrame frame;

    public DialogCloseListener(AppendTextFrame frame) {
        this.frame = frame;
    }

    @Override
    public void windowClosing(WindowEvent e) {
        JDialog dialog = (JDialog)(e.getWindow());
        frame.appendText2TextPane(dialog.getTitle() + " closing...");
        super.windowClosing(e);
    }

    @Override
    public void windowClosed(WindowEvent e) {
        JDialog dialog = (JDialog)(e.getWindow());
        frame.appendText2TextPane(dialog.getTitle() + " closed...");
        super.windowClosed(e);
    }
}
